home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
tbbs
/
prgsourc.zip
/
FLAGS.ZIP
/
SYSFLAG.PRG
< prev
next >
Wrap
Text File
|
1996-03-03
|
7KB
|
376 lines
SET EXCLUSIVE ON
SET FORMAT TO fscr NOCLEAR
SET INTENSITY OFF
SELECT a
USE ail INDEX ails
SELECT b
USE vflags INDEX pik
DO Menu
k= " "
SET COLOR TO N/N
@ 0,0 GET k
DO WHILE .T.
READ
DO CASE
CASE LastKey() = 27
QUIT
CASE LastKey() = 65 .OR. LastKey() = 97 && A 0R a .AIL
@ 0,0 CLEAR
DO Block
DO Menu
CASE LastKey() = 70 .OR. LastKey() = 102 && F 0R f Files
@ 0,0 CLEAR
DO Flagview
DO Menu
CASE LastKey() = 73 .OR. LastKey() = 105 && I 0R i Index
@ 0,0 CLEAR
DO Inx
DO Menu
CASE LastKey() = 76 .OR. LastKey() = 108 && L 0R l List files
@ 0,0 CLEAR
DO Filelist
DO Menu
ENDCASE
ENDDO
QUIT
**************************************************
PROCEDURE Inx
SET COLOR TO W+/N
txt = "textfile"
@ 1,5 SAY "Enter the name of the text file (no path or extension)"
@ 2,5 SAY "to index: "
SET COLOR TO GR+/N
@ 2,15 GET txt PICTURE "@K!"
READ
SET COLOR TO W+/N
SEEK txt
IF .NOT. Found()
APPEND BLANK
REPLACE pfile WITH txt
ENDIF
txt = homepath() + "PIKS\" + RTrim(txt) + ".TXT"
b = fMaxLen()
IF b > 5120
tb = 2048
pb = 2048
ELSE
IF buf > 3072
tb = 1024
pb = 1024
ELSE
IF buf > 512
tb = 256
pb = 256
ELSE
tb = 0
pb = 0
ENDIF
ENDIF
ENDIF
FOPEN t (txt) 10 tb
IF t < 0
DO er WITH 1
ENDIF
@ 4,5 SAY "Examining file..."
pmax = 1
lines = 0
DO WHILE .T.
FLREAD t tm line
IF tm > 0
line = LTrim(RTrim(CRTrim(line)))
n = Len(line)
IF n = 0
EXIT
ENDIF
IF n > pmax
pmax = n
ENDIF
ELSE
EXIT
ENDIF
lines = lines + 1
ENDDO
@ 6,5 SAY "Number of lines in file:"
SET COLOR TO GR+/N
@ 6,31 SAY LTrim(Str(lines))
SET COLOR TO W+/N
IF lines > 15876
DO er WITH 2
ENDIF
@ 8,5 SAY "Creating .PIK file..."
txt = Stuff(txt,Len(txt)-2,3,"PIK")
FCREATE p (txt) 13 0 pb
IF p < 0
DO er WITH 3
ENDIF
FSEEK t tp 0 0
x = 0
DO WHILE .T.
FLREAD t tm line
IF tm > 0
line = LTrim(RTrim(CRTrim(line)))
p1 = Len(line)
IF p1 = 0
EXIT
ENDIF
IF pmax = p1
line = line + Chr(13) + Chr(10)
ELSE
line = line + Replicate(Chr(32),pmax-p1) + Chr(13) + Chr(10)
ENDIF
p1 = Len(line)
IF x = 0
Oldp1 = p1
ENDIF
IF p1 # Oldp1
DO er WITH 4
ENDIF
FLWRITE p pm line
IF pm < 1
DO er WITH 5
ENDIF
x = x + 1
ELSE
EXIT
ENDIF
ENDDO
IF lines # x
DO er WITH 6
ENDIF
REPLACE plen WITH x
REPLACE pwidth WITH Oldp1
IF x > 126
REPLACE flen WITH 2
ELSE
REPLACE flen WITH 1
ENDIF
@ 10,5 SAY "Flag will use"
SET COLOR TO GR+/N
@ 10,19 SAY LTrim(Str(flen))
SET COLOR TO W+/N
IF flen = 1
@ 10,21 SAY "flag position."
ELSE
@ 10,21 SAY "flag positions."
ENDIF
@ 11,5 SAY "Enter the initial flag position:"
SET COLOR TO GR+/N
@ 11,38 GET fpos PICTURE "@KZB 99"
READ
FCLOSE p
SET COLOR TO W+/N
@ 13,5 SAY "Flag file indexing completed."
SET COLOR TO GR+/N
@ 14,15 SAY "<ANY KEY>"
k = InKey(40)
RETURN
**************************************************
PROCEDURE er
PARAMETERS e
DO CASE
CASE e = 1
err = "Error opening .TXT file."
CASE e = 2
err = "Maximum 15,876 items in list. List too long."
CASE e = 3
err = "Error creating .PIK file."
CASE e = 4
err = "Error formatting .PIK file."
CASE e = 5
err = "Error writing to .PIK file."
CASE e = 6
err = "Error in length of .PIK file."
ENDCASE
SET COLOR TO W+/N
@ 10,5 SAY err
SET COLOR TO GR+/N
@ 11,5 SAY "<ANY KEY>"
k = InKey (30)
QUIT
RETURN
**************************************************
PROCEDURE Filelist
SET COLOR TO W+/N
mask = HomePath() + "PIKS\*.*"
f1 = FindFirst(fil,(mask))
@ 1,5 SAY f1
x = 1
DO WHILE Len(f1) > 0
f1 = FindNext(fil)
@ 1+x,5 SAY f1
x = x +1
ENDDO
@ Row()+2,5 SAY "<ANY KEY>"
k = Inkey(0)
RETURN
**************************************************
PROCEDURE Menu
SET COLOR TO N/N
@ 0,0 CLEAR
SET COLOR TO W+/N
@ 0,5 SAY "<A> Block .AIL"
@ 1,5 SAY "<F> View flag positions"
@ 2,5 SAY "<I> Index .TXT file to .PIK file"
@ 3,5 SAY "<L> List files in \PIKS subdirectory"
@ 4,5 SAY "<Esc> Quit"
RETURN
**************************************************
PROCEDURE Flagview
SET COLOR TO W+/N
COUNT TO cnt
GOTO TOP
@ 1,2 SAY "File/Identifier"
@ 1,22 SAY "F. Position"
@ 1,35 SAY "F. Length"
@ 1,47 SAY "Length of line"
@ 1,62 SAY "Length of File"
x = 1
DO WHILE .T.
@ x+2,5 SAY pfile
@ x+2,25 SAY LTrim(Str(fpos))
@ x+2,37 SAY LTrim(Str(flen))
@ x+2,49 SAY LTrim(Str(pwidth))
@ x+2,65 SAY LTrim(Str(plen))
IF x = cnt
EXIT
ENDIF
SKIP
x = x + 1
ENDDO
@ Row()+2,5 SAY "<ANY KEY>"
k = Inkey(0)
RETURN
PROCEDURE Block
SELECT a
SET COLOR TO W+/N
COUNT TO cnt
GOTO TOP
@ 1,22 SAY ".AIL File"
@ 1,47 SAY "Blocked"
x = 1
DO WHILE .T.
@ x+2,25 SAY ail
IF blocked
@ x+2,49 SAY "Blocked"
ELSE
@ x+2,49 SAY "Open"
ENDIF
IF x = cnt
EXIT
ENDIF
SKIP
x = x + 1
ENDDO
x = 1
GOTO TOP
SET COLOR TO GR+/B
@ x+2,25 SAY ail
k= " "
SET COLOR TO N/N
@ 0,0 GET k
DO WHILE .T.
READ
SET COLOR TO W+/N
DO CASE
CASE LastKey() = 24 && Up
IF x = 1
LOOP
ENDIF
@ x+2,25 SAY ail
x = x - 1
SKIP -1
SET COLOR TO GR+/B
@ x+2,25 SAY ail
CASE LastKey() = 24 && Down
IF x = cnt
LOOP
ENDIF
@ x+2,25 SAY ail
x = x + 1
SKIP
SET COLOR TO GR+/B
@ x+2,25 SAY ail
CASE LastKey() = 27 && <Esc> =
EXIT
CASE LastKey() = 13 && <Enter> = Block
IF blocked
REPLACE blocked WITH .F.
@ x+2,49 SAY "Open"
ELSE
REPLACE blocked WITH .T.
@ x+2,49 SAY "Blocked"
ENDIF
ENDCASE
ENDDO
SELECT b
RETURN